<?php

declare(strict_types=1);

namespace app\validate;

use think\Validate;

class GoodsVal extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'title' => ['require', 'length' => '2,50'],
        'thum' => ['require'],
        'goods_img' => ['require'],
        'price' => ['require'],
        'storage' => ['require'],
        'remark' => ['length' => '0,200'],
        'content' => ['require']

    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'title.require' => '标题不可为空',
        'title.length' => '标题必须2~50个字符',
        'thum.require' => '商品缩略图不可为空',
        'goods_img.require' => '商品图片不可为空',
        'price.require' => '商品价格不可为空',
        'storage.require' => '商品库存不可为空',
        'remark.length' => '商品描述不可超过200个字符',
        'content.require' => '商品内容不可为空'
    ];
}
